﻿package com.csdn;

import java.util.ArrayList;
import java.util.Scanner; //键盘输入

public class Demo7 {

	public static void main(String[] args) {
//		strArray();
		scStu();
	}
	public static   void scStu() {
		
	      ArrayList<Student> array=new ArrayList<Student>() ;
	        
	      strAddArray(array);
	      strAddArray(array);
	      strAddArray(array);
	          
	         for(int i=0;i<array.size();i++) {
	        	 Student s1 = array.get(i);
		        	System.out.println(s1.getAge()+"--"+s1.getName());
		        }
	       
		}
	
	
	
	public static   void strAddArray(ArrayList<Student> array) {
		Scanner sc = new Scanner(System.in);
        String name =sc.nextLine();
        String age =sc.nextLine();
      
        Student s=new Student();
        s.setName(name);
        s.setAge(age);
  
         array.add(s);
	}
	
	
	public static   void strArray() {
		
	      ArrayList<String> array=new ArrayList<String>() ;
	        array.add("zcasd");
	        array.add("2");
	        array.add("c");
	        System.out.println(array); //string数组 直接打印
	        
	        //遍历数组
	        for(int i=0;i<array.size();i++) {
	        	String s = array.get(i);
	        	System.out.println(s);
	        }
	        
	        
		}
	public static void stuArray() {
		
      ArrayList<Student> array=new ArrayList<Student>() ;
      Student s1 =new Student("sasdf",60);
      s1.setAge(30);
      s1.setName("aasd");
      array.add(s1);
      Student s2 =new Student("s2s2s2",20);
      Student s3 =new Student("s3s3s2",30);
      array.add(s2);
      array.add(s3);
      for(int i=0;i<array.size();i++) {
    	  Student ss=array.get(i);
    	  System.out.println(ss.getAge());
      }
     
      System.out.println(array.get(1));   //??? 这打印的是地址  
	}
	
	

}
